<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include_once("conn.php");
$type=$_COOKIE['type'];
$id=$_COOKIE['id'];

$sql=selectSQL($type,$id);
$result=mysql_query($sql);
$row = mysql_fetch_row($result);
?>
<table border="1" bordercolor="#ffffff" style="BORDER-COLLAPSE: collapse; color: #FFF"; width="50%" bgcolor="#6589d1" class="h">
  <tr style="text-align: center">
    <td width="21%">ID号</td>
    <td width="79%"><?=$row[0]?></td>
  </tr>
  <tr style="text-align: center">
    <td>姓名</td>
    <td><?=$row[1]?></td>
  </tr>
  <tr style="text-align: center">
    <td>性别</td>
    <td><?=$row[3]==0?"男":"女"?></td>
  </tr>
  <tr style="text-align: center">
    <td>学院</td>
    <td><?=$row[4]?></td>
  </tr>
<?php
if ($type==0){
?>
	<tr style="text-align: center">
    	<td>专业</td>
    	<td><?=$row[5]?></td>
  	</tr>
<?php
}
?>
  <tr style="text-align: center">
    <td>出生年月</td>
    <td><?php
    echo $type==0? $row[6].".".$row[7]:$row[5].".".$row[6]?></td>
  </tr>
</table>
<?php
mysql_close($conn);

function selectSQL($type,$id){
	switch ($type) {
		case 0:
			$sql = "SELECT * FROM student WHERE `id` = '$id'";
			break;
		case 1:
			$sql = "SELECT * FROM teacher WHERE `id` = '$id'";
			break;
		case 2:
			$sql = "SELECT * FROM admin WHERE `id` = '$id'";
			break;
	}
	return $sql;
}
?>
</body>
</html>